package cn.wongshu.student.controller;


import cn.wongshu.student.pojo.Comment;
import cn.wongshu.student.pojo.Message;
import cn.wongshu.student.pojo.Result;
import cn.wongshu.student.pojo.StatusCode;
import cn.wongshu.student.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/comment")
public  class CommentController {

   @Autowired
    private CommentService commentService;


    @PostMapping("save")
    public Result save(@RequestBody Comment comment){
        comment.setCreateDate(new Date());
       commentService.save(comment);
       return new Result(true, StatusCode.Ok, Message.ADD_SUCCESS);

    }
}






